home *** CD-ROM | disk | FTP | other *** search
- SWAGOLX.EXE (c) 1993 GDSOFT ALL RIGHTS RESERVED 00001 1 05-25-9408:11ALL MIKE DICKSON DESQVIEW API Routines SWAG9405 118 t {π********************************************************************π* *π* DESQview API routines *π* for Turbo Pascal 6.0 *π* by Jonathan L. Zarate *π* Released to the Public Domain *π* *π********************************************************************π}π{π ** Please refer to Ralf Brown's Interrupt Listπ ** for additional information.π}ππUnit DV;ππInterfaceππTypeπ Msg_Write2 = recordπ len : longint;π str : pointer;π end;π Msg_Write2_NewWin = recordπ len : longint;π str : pointer;π handle : pointer;π end;ππconstπ{ Stream Types }π WinStream = $00;π QueryStream = $01;π ManagerStream = $10;ππ{ Manager Streams }π MStream_MoveHoriz = $00; { horizontal movement }π MStream_MoveVert = $01; { vertical movement }π MStream_ChangeWidth = $02; { width change }π MStream_ChangeHeight = $03; { height change }π MStream_ScrollHoriz = $04; { horizontal scroll }π MStream_ScrollVert = $05; { vertical scroll }π MStream_CloseWindow = $06; { close window option }π MStream_HideWindow = $07; { hide window option }π MStream_FreezeApp = $08; { freeze window option }π MStream_ScissorsMenu = $0E; { scissors menu }π MStream_MainMenu = $10; { main DESQview menu }π MStream_SwitchWinMenu= $11; { switch windows menu }π MStream_OpenWinMenu = $12; { open windows menu }π MStream_QuitMenu = $13; { quit menu }ππ{ Window/Query streams }π WStream_CursorRow = $A0; { Cursor row }π WStream_CursorColumn = $A1; { Cursor Column }π WStream_ScrollTopRow = $A2; { Top row of scrolling region }ππ{ DVError Constants }π DVErrorMouEither = 00; { use either mouse buttons to remove window }π DVErrorMouRight = 32; { use right mouse button to remove window }π DVErrorMouLeft = 64; { use left mouse button to remove window }π DVErrorBeep = 128; { beep on error }π{ ----------------------- }ππconstπ InDV : boolean = false; { In DESQview flag }π DV_Version : word = $0000; { DESQview version }ππvarπ DVArray : array[1..80] of byte; { stream array }ππfunction DVInit : pointer;πprocedure DVGetVersion;πfunction DVGetShadowSeg( VideoSeg : word ) : word;πprocedure DVPause;πprocedure DVBeginC;πprocedure DVEndC;πfunction DVAPPNum : word;πprocedure DVSendMsg( Handle : pointer; _bh, _bl : byte; size : word; var param);πprocedure DVStream( Handle : pointer; mode : byte; params : string );πfunction DVGetHandle( HandleType : byte ) : pointer;πprocedure DVSound( Handle : pointer; frequency, duration : word );πprocedure DVError( Handle : pointer; xsize, ysize : byte; msg : string; params:byte);πprocedure DVAPILevel( major, minor : byte );πprocedure DVWrite( Handle : pointer; s : string );πprocedure DVWriteln( Handle : pointer; s : string );πfunction DVNewWin( x, y : word ) : pointer;πprocedure DVFree( var Handle : pointer );πfunction DVTimer_New : pointer;πprocedure DVTimer_Start( Handle : pointer; Time : longint );πfunction DVTimer_Len( Handle : pointer ) : longint;π{ ---- Window Streams ---- }πprocedure DVClear( Handle : pointer );πprocedure DVRedraw( Handle : pointer );πprocedure DVResize( Handle : pointer; x, y : byte );πprocedure DVMove( Handle : pointer; x, y : shortint );πprocedure DVTitle( Handle : pointer; title : string );πprocedure DVMove2( Handle : pointer; x, y : shortint );πprocedure DVResize2( Handle : pointer; x, y : shortint );πprocedure DVSetAttr( Handle : pointer; color : byte );πprocedure DVFrameAttr( Handle : pointer; color : byte );πprocedure DVFrameOn( Handle : pointer; b : boolean );πprocedure DVWinUnHide( Handle : pointer );πprocedure DVWinHide( Handle : pointer );πprocedure DVGotoXY( Handle : pointer; x, y : byte );πprocedure DVSetVirtualWinSize( Handle : pointer; x, y : byte );π{ -- Manager Streams -- }πprocedure DVAllow( Handle : pointer; command : byte );πprocedure DVDisallow( Handle : pointer; command : byte );πprocedure DVForeOnly( Handle : pointer; b : boolean );πprocedure DVMinWinSize( Handle : pointer; x, y : byte );πprocedure DVMaxWinSize( Handle : pointer; x, y : byte );πprocedure DVForceForeground( Handle : pointer );πprocedure DVForceBackground( Handle : pointer );πprocedure DVTopProcess( Handle : pointer );πprocedure DVBottomProcess( Handle : pointer );π{ ---- Query Streams ---- }πprocedure DVQSize( Handle : pointer; var x, y : byte );πprocedure DVQPos( Handle : pointer; var x, y : shortint );πprocedure DVQVirtualWinSize( Handle : pointer; var x, y : byte );πfunction DVWhereX( Handle : pointer ) : shortint;πfunction DVWhereY( Handle : pointer ) : shortint;ππImplementationππfunction DVInit : pointer;πbeginπ { get DESQview version & get our window handle }π DVGetVersion;π if InDV then DVInit:=DVGetHandle(1);πend;ππprocedure DVGetVersion; assembler;πasmπ { get DESQview version/set InDV flag }π mov cx,'DE'π mov dx,'SQ'π mov ax,2b01hπ int 21hπ cmp al,0ffhπ je @GV1π mov DV_Version,bxπ mov InDV,Trueπ jmp @GV2π@GV1:π mov InDV,Falseπ@GV2:πend;ππfunction DVGetShadowSeg( VideoSeg : word ) : word; assembler;πasmπ { get task's shadow buffer & start shadowing }π mov ax,VideoSegπ mov es,axπ mov di,0π mov ah,0fehπ int 10hπ mov ax,esπ { di=offset ??don't know if used?? }πend;ππprocedure DVPause; assembler;πasmπ { give up CPU time }π mov ax,1000hπ int $15πend;ππprocedure DVBeginC; assembler;πasmπ { begin critical region }π mov ax,101bhπ int $15πend;ππprocedure DVEndC; assembler;πasmπ { end critical region }π mov ax,101chπ int $15πend;ππfunction DVAPPNum : word; assembler;πasmπ { get application's switch number }π mov ax,0de07hπ int 15hπend;ππprocedure DVSendMsg( Handle : pointer; _BH, _BL : byte;π size : word; var param ); assembler;πasmπ std { string goes backwards }π mov dx,sp { save sp }ππ mov cx,size { load size of param }π jcxz @SM2 { if zero then don't push anything }ππ mov bx,ds { save ds }ππ lds si,param { load address of param }π add si,cx { start from the top }π dec si { minus 2 }π dec si { ^^^^^^^ }π shr cx,1 { cx:=cx div 2 }π@SM1:π lodsw { load 1 word }π push ax { push it }π loop @SM1 { if cx > 0 loop }ππ mov ds,bx { restore ds }π@SM2:π les di,Handle { get handle }π mov ax,es { move es to ax for compare }π cmp ax,0 { if segment is 0 then }π je @SM3 { don't push handle }π push es { push segment }π push di { push offset }π@SM3:π mov ah,$12π mov bh,_bhπ mov bl,_blπ int $15 { call dv }ππ cld { string goes forward }π mov ax,sp { calculate the number of }π mov cx,dx { returned parameter(s) }π sub cx,ax { in stack }ππ jcxz @SMX { exit if none }π les di,param { load address of param }π add di,sizeπ shr cx,1 { cx:=cx div 2 }π@SM4:π pop axπ stoswπ loop @SM4π@SMX:πend;ππfunction DVGetHandle( HandleType : byte ) : pointer; assembler;πasmπ { return object handle }π mov ah,$12π mov bh,$00π mov bl,HandleTypeπ int $15π pop axπ pop dxπend;ππprocedure DVSound( Handle : pointer; frequency, duration : word ); assembler;πasmπ { generate a sound }π mov ax,$1019π mov bx,frequencyπ mov cx,duration { in 18.2 ticks/sec }π int $15πend;ππprocedure DVError( handle : pointer; xsize, ysize : byte; msg : string; params: byte);πassembler;πasmπ { pop-up an error box }π {π use DVERRORxxxxx for PARAMSπ example: DVError(Handle1, 80, 25, 'Don't Touch That!',π DVErrorMouEither+DVErrorBeep);π }π mov ch,xsizeπ mov cl,ysize;π mov bh,paramsπ les dx,Handleπ mov dx,esπ les di,msgπ mov bl,es:[di]π inc diπ mov ax,$101Fπ int $15πend;ππprocedure DVAPILevel( major, minor : byte ); assembler;πasmπ { define the minimum API revision level than the program requires }π mov bh,majorπ mov bl,minorπ mov ax,0de0bhπ int 15hπend;ππprocedure DVStream( handle : pointer; mode : byte; params : string );πvarπ Msg : Msg_Write2;πbeginπ { send a stream of opcode(s) }π DVArray[1]:=$1B;π DVArray[2]:=mode; { stream mode }π DVArray[3]:=length(params);π DVArray[4]:=00;π move(params[1],DVArray[5],length(params));π with Msg doπ beginπ Str:=@DVArray;π Len:=Length(params)+4;π end;π DVSendMsg(Handle, $05, ord((handle=nil)), sizeof(Msg), Msg);π { Meaning of "ord((handle=nil))" }π { If handle=nil then return 1 else return 0 }πend;ππprocedure DVWrite( Handle : pointer; s : string );πvarπ Msg : Msg_Write2;πbeginπ { write a string }π with Msg doπ beginπ str:=@s[1];π len:=length(s);π end;π DVSendMsg(Handle, $05, Ord((Handle=Nil)), Sizeof(Msg), Msg );πend;ππprocedure DVWriteln( Handle : pointer; s : string );πbeginπ DVWrite(Handle, s+#13#10 );πend;ππfunction DVNewWin( x, y : word ) : pointer;πvarπ Msg : Msg_Write2_NewWin;πbeginπ { allocate new window ( X and Y are the window's size & virtual size }π DVArray[1]:=$1B;π DVArray[2]:=$00;π DVArray[3]:=$04;π DVArray[4]:=$00;π DVArray[5]:=$E6;π DVArray[6]:=y; { Y-Size }π DVArray[7]:=x; { X-Size }π With Msg doπ beginπ Len:=$07;π Str:=@DVArray;π Handle:=Nil;π DVSendMsg( Nil, $05, $01, Sizeof(Msg)-4, Msg);π DVNewWin:=Handle;π end;πend;ππprocedure DVFree( var Handle : pointer );πbeginπ { free a handle (close a window/free a timer/etc..) }π DVSendMsg(Handle, $02, $00, $00, Handle );π Handle:=Nil;πend;ππfunction DVTimer_New : pointer;πvarπ Handle : pointer;πbeginπ { allocate a new timer }π DVSendMsg( Nil, $01, $0B, $00, Handle );π DVTimer_New:=Handle;πend;ππprocedure DVTimer_Start( Handle : pointer; Time : longint );πbeginπ { start a timer countdown (TIME is in 1/100 of a second) }π DVSendMsg(Handle, $0a, $00, sizeof(Time), Time);πend;ππfunction DVTimer_Len( Handle : pointer ) : longint;πvarπ Len : longint;πbeginπ { get current timer value (in 1/100 of a second) }π DVSendMsg(Handle, $09, $00, $00, Len);π DVTimer_Len:=Len;πend;ππ{ ---- Window Streams ---- }ππprocedure DVClear( Handle : pointer );πbeginπ { clear window }π DVStream(Handle, WinStream, chr($E3))πend;ππprocedure DVRedraw( Handle : pointer );πbeginπ { redraw window }π DVStream(Handle, WinStream, chr($E4))πend;ππprocedure DVResize( Handle : pointer; x, y : byte );πbeginπ { resize window }π DVStream(Handle, WinStream, chr($C3)+chr(y)+chr(x));πend;ππprocedure DVMove( Handle : pointer; x, y : shortint );πbeginπ { move the window }π DVStream(Handle, WinStream, chr($C2)+chr(y)+chr(x))πend;ππprocedure DVTitle( Handle : pointer; title : string );πbeginπ { change window title }π DVStream(Handle, WinStream, chr($EF)+title[0]+title)πend;ππprocedure DVMove2( Handle : pointer; x, y : shortint );πbeginπ { set window position relative to the current position }π { use negative (-1) values to move up/left }π DVStream(Handle, WinStream, chr($CA)+chr(y)+chr(x));πend;ππprocedure DVResize2( Handle : pointer; x, y : shortint );πbeginπ { set window size relative to the current size }π { use negative (-1) values to shrink window }π DVStream(handle, WinStream, chr($CB)+chr(y)+chr(x));πend;ππprocedure DVSetAttr( Handle : pointer; color : byte );πbeginπ { set the output color }π DVStream(Handle, WinStream, chr($E2)+chr(color));πend;ππprocedure DVFrameAttr( Handle : pointer; color : byte );πbeginπ { set the frame color }π DVStream(Handle, WinStream, chr($ED)+chr($FF)+chr($08)+π chr(color)+chr(color)+chr(color)+chr(color)+π chr(color)+chr(color)+chr(color)+chr(color));πend;ππprocedure DVFrameOn( Handle : pointer; b : boolean );πbeginπ{ must use DVRedraw to remove the frame }π if b then DVStream(Handle, WinStream, chr($D6))π else DVStream(Handle, WinStream, chr($D7))πend;ππprocedure DVWinUnHide( Handle : pointer );πbeginπ { unhide a window }π DVStream(Handle, WinStream, chr($D4));πend;ππprocedure DVWinHide( Handle : pointer );πbeginπ { hide a window }π DVStream(Handle, WinStream, chr($D5));πend;ππprocedure DVGotoXY( Handle : pointer; x, y : byte );πbeginπ { positions the cursor at X, Y }π DVStream(Handle, WinStream, chr($C0)+chr(y-1)+chr(x-1));πend;ππprocedure DVSetVirtualWinSize( Handle : pointer; x, y : byte );πbeginπ { set window's virtual size }π DVStream(Handle, WinStream, chr($AB)+chr(x));π DVStream(Handle, WinStream, chr($AA)+chr(y));πend;ππ{ ---- Query Streams ---- }ππprocedure DVQSize( Handle : pointer; var x, y : byte );πbeginπ { get the window size }π DVStream(Handle, QueryStream, chr($C3));π { result is in DVArray[6..7] }π y:=DVArray[6];π x:=DVArray[7];πend;ππprocedure DVQPos( Handle : pointer; var x, y : shortint );πbeginπ { get the window position }π DVStream(Handle, QueryStream, chr($C2));π { result is in DVArray[6..7] }π y:=DVArray[6];π x:=DVArray[7];πend;ππprocedure DVQVirtualWinSize( Handle : pointer; var x, y : byte );πbeginπ { get virtual window size }π DVStream(Handle, QueryStream, chr($AA));π Y:=DVArray[6];π DVStream(Handle, QueryStream, chr($AB));π X:=DVArray[6];πend;ππfunction DVWhereX( Handle : pointer ) : shortint;πbeginπ { return the cursor's X position }π DVStream( Handle, QueryStream, chr($A1) );π DVWhereX:=DVArray[6];πend;ππfunction DVWhereY( Handle : pointer ) : shortint;πbeginπ { return the cursor's Y position }π DVStream( Handle, QueryStream, chr($A0) );π DVWhereY:=DVArray[6];πend;ππ{ --- Manager Stream Procedures --- }ππprocedure DVAllow( Handle : pointer; command : byte );πbeginπ { disallow a command (see constants "MStream_xxxxxx") }π DVStream(Handle, ManagerStream, chr(command));πend;ππprocedure DVDisallow( Handle : pointer; command : byte );πbeginπ { disallow a command (see constants "MStream_xxxxxx") }π DVStream(Handle, ManagerStream, chr(command+$20));πend;ππprocedure DVForeOnly( Handle : pointer; b : boolean );πbeginπ { B=TRUE if application runs on foreground only }π if b then DVStream(Handle, ManagerStream, chr($86))π else DVStream(Handle, ManagerStream, chr($87));πend;ππprocedure DVMinWinSize( Handle : pointer; x, y : byte );πbeginπ { define window's minimum size }π DVStream(Handle, ManagerStream, chr($88)+chr(y)+chr(x));πend;ππprocedure DVMaxWinSize( Handle : pointer; x, y : byte );πbeginπ { define window's maximum size }π DVStream(Handle, ManagerStream, chr($89)+chr(y)+chr(x));πend;ππprocedure DVForceForeground( Handle : pointer );πbeginπ { force process to run into foreground }π DVStream(Handle, ManagerStream, chr($C1));πend;ππprocedure DVForceBackground( Handle : pointer );πbeginπ { force process to run into background }π DVStream(Handle, ManagerStream, chr($C9));πend;ππprocedure DVTopProcess( Handle : pointer );πbeginπ { make current window topmost in process }π DVStream( Handle, ManagerStream, chr($C2) );πend;ππprocedure DVBottomProcess( Handle : pointer );πbeginπ { make current window bottom-most in process }π DVStream( Handle, ManagerStream, chr($CA) );πend;ππend.π